import { createStore, applyMiddleware, compose } from 'redux';
import reducer from './reducer'
import thunk from 'redux-thunk'; // 异步reducer 变化 
import logger from 'redux-logger'; // redux 调试更优秀 ! 记录redux改变

// 如果没有安装redux-dev-tool  compose 百搭功能    
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
    || compose;

const store = createStore(reducer,
    // 合并中间件
    compose(
        // UI组件   中间件s redux-thunk -> applyMiddleware启用 logger   Store 
        composeEnhancers(applyMiddleware(thunk)), // 异步
        applyMiddleware(logger) // 有多少中间件，加多少
    )
)

export default store